import { ImagePreview } from 'vant';
import config from '@/env/config';
const imagesUrl = config.imagesUrl;
export const guid = () => {
    function S4() {
        return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
    }
    return (`${S4() + S4() }${ S4() }${S4()}${S4() }${S4()}${S4()}${S4()}`);
};


export const loadStyle = url => {
    const link = document.createElement('link');
    link.type = 'text/css';
    link.rel = 'stylesheet';
    link.href = url;
    const head = document.getElementsByTagName('head')[0];
    head.appendChild(link);
};

export const imgDetail = (index, list) => {
    let imgList = [];
    list.forEach(ele => {
        imgList.push(`${imagesUrl}/${ele.data || ele}`)
    })
    ImagePreview({
        images: imgList,
        startPosition: index
    });
}